package edu.ck.imgTest;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public class imgTest extends Activity {
    /** Called when the activity is first created. */
	private TickHandler tickhandler;
	private ViewTest viewTest;
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        viewTest = new ViewTest(this);
        setContentView(viewTest);
    }
    
    @Override
    public void onResume(){
    	super.onResume();
    	tickhandler = new TickHandler();
    	tickhandler.sleep(0);
    }
    
    @Override
    public void onPause(){
    	super.onPause();
    	tickhandler = null;
    }
    
	public class TickHandler extends Handler{
    	@Override
    	public void handleMessage(Message msg){
    		viewTest.invalidate();
    		if(tickhandler != null) tickhandler.sleep(100);
    	}
    	
    	public void sleep(long delayMills){
    		removeMessages(0);
    		sendMessageDelayed(obtainMessage(0), delayMills);
    	}
    }
}